﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using AutoR.Models;
using Prism.Commands;
using Prism.Mvvm;
using Prism.Navigation;

namespace AutoR.ViewModels.Tasks
{
	// Token: 0x02000085 RID: 133
	public class ShipTypeSelectViewModel : BindableBase, INavigationAware, INavigatedAware, INavigatingAware
	{
		// Token: 0x17000089 RID: 137
		// (get) Token: 0x06000249 RID: 585 RVA: 0x00045EB5 File Offset: 0x000440B5
		public DelegateCommand ChangeCommand { get; }

		// Token: 0x1700008A RID: 138
		// (get) Token: 0x0600024A RID: 586 RVA: 0x00045EBD File Offset: 0x000440BD
		// (set) Token: 0x0600024B RID: 587 RVA: 0x00045EC8 File Offset: 0x000440C8
		public IList<ShipType> sourceList
		{
			[CompilerGenerated]
			get
			{
				return this.<sourceList>k__BackingField;
			}
			[CompilerGenerated]
			set
			{
				if (object.Equals(this.<sourceList>k__BackingField, value))
				{
					return;
				}
				this.<sourceList>k__BackingField = value;
				this.OnPropertyChanged(<>PropertyChangedEventArgs.sourceList);
			}
		}

		// Token: 0x1700008B RID: 139
		// (get) Token: 0x0600024C RID: 588 RVA: 0x00045EF8 File Offset: 0x000440F8
		// (set) Token: 0x0600024D RID: 589 RVA: 0x00045F00 File Offset: 0x00044100
		public List<SelectItem> List
		{
			[CompilerGenerated]
			get
			{
				return this.<List>k__BackingField;
			}
			[CompilerGenerated]
			set
			{
				if (object.Equals(this.<List>k__BackingField, value))
				{
					return;
				}
				this.<List>k__BackingField = value;
				this.OnPropertyChanged(<>PropertyChangedEventArgs.List);
			}
		}

		// Token: 0x0600024E RID: 590 RVA: 0x00045F30 File Offset: 0x00044130
		public ShipTypeSelectViewModel()
		{
			this.<List>k__BackingField = new List<SelectItem>();
			base..ctor();
			this.ChangeCommand = new DelegateCommand(new Action(this.OnChangeCommandExecuted));
		}

		// Token: 0x0600024F RID: 591 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatedFrom(INavigationParameters parameters)
		{
		}

		// Token: 0x06000250 RID: 592 RVA: 0x00045F5C File Offset: 0x0004415C
		public void OnNavigatedTo(INavigationParameters parameters)
		{
			if (parameters.ContainsKey("list"))
			{
				this.sourceList = (IList<ShipType>)parameters["list"];
				int[] array = new int[]
				{
					1,
					2,
					3,
					4,
					5,
					6,
					7,
					8,
					9,
					10,
					11,
					12,
					13,
					14,
					15,
					16,
					23,
					24
				};
				string[] array2 = new string[]
				{
					"航母",
					"轻母",
					"装母",
					"战列",
					"航战",
					"战巡",
					"重巡",
					"航巡",
					"雷巡",
					"轻巡",
					"重炮",
					"驱逐",
					"潜母",
					"潜艇",
					"炮潜",
					"补给",
					"导驱",
					"防驱"
				};
				for (int i = 0; i < 18; i++)
				{
					this.List.Add(new SelectItem
					{
						Name = array2[i],
						ID = array[i],
						Selected = this.sourceList.Contains((ShipType)array[i])
					});
					this.List = (from x in this.List
					orderby !x.Selected
					select x).ToList<SelectItem>();
				}
			}
		}

		// Token: 0x06000251 RID: 593 RVA: 0x0004067F File Offset: 0x0003E87F
		public void OnNavigatingTo(INavigationParameters parameters)
		{
		}

		// Token: 0x06000252 RID: 594 RVA: 0x000460BC File Offset: 0x000442BC
		private void OnChangeCommandExecuted()
		{
			this.sourceList.Clear();
			foreach (SelectItem selectItem in from i in this.List
			where i.Selected
			select i)
			{
				this.sourceList.Add((ShipType)selectItem.ID);
			}
		}
	}
}
